import { moduleTools, defineConfig } from '@edenx/module-tools';

export default defineConfig({
  plugins: [moduleTools()],
  buildConfig: {
    alias: {
      '@': './src',
    },
  },
  buildPreset({ preset }) {
    const { NPM_LIBRARY } = preset;
    return [
      ...NPM_LIBRARY,
      {
        format: 'esm',
        target: 'es5',
        buildType: 'bundle',
        outDir: './dist/es5',
        autoExternal: {
          dependencies: false,
        },
        externals: [
          '@dp/tea-sdk-common',
          '@slardar/integrations',
          '@slardar/web',
          'axios',
          'byted-tea-sdk',
          'lodash-es',
        ],
        dts: {
          distPath: './',
          abortOnError: true,
          only: false,
        },
      },
      {
        format: 'esm',
        target: 'es6',
        buildType: 'bundle',
        outDir: './dist/lynx',
        input: ['src/lynx/index.ts'],
        dts: {
          distPath: './',
          abortOnError: true,
          only: false,
        },
      },
    ];
  },
});
